<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order', function (Blueprint $table) {
            $table->increments('id');
            $table->Integer('userId')->comment('用户id');
            $table->Integer('versionId')->comment('版本id');
            $table->string('name')->comment('版本名称');
            $table->string('orderNo')->comment('订单号')->unique();
            $table->string('term')->comment('订单产品期限名称');
            $table->Integer('price')->comment('订单价格');
            $table->Integer('discount')->comment('优惠价格');
            $table->string('outTradeNo')->comment('支付流水号')->nullable();
            $table->tinyInteger('type')->comment('支付类型 1:微信 2:支付宝');
            $table->tinyInteger('status')->comment('支付状态 1：未支付 2：已支付')->default(1);
            $table->integer('createdAt')->comment('创建时间');
            $table->integer('updatedAt')->comment('最后更新时间');
        });
        DB::statement("ALTER TABLE `order` comment '订单信息表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order');
    }
}
